﻿<%@ Page Title="Edit Repair Model" Theme="POSSystem" Language="C#" MasterPageFile="~/EditPages/Popup.Master" AutoEventWireup="true" CodeBehind="EditRepairModel.aspx.cs" Inherits="WebUI.EditPages.EditRepairModel" %>

<%@ Register Src="~/Controls/POSControls/RepairModelProblemListCtrl.ascx" TagName="RepairModelProblemList" TagPrefix="uc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PopupHeadHolder" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="PopupToolbarHolder" runat="server">
    <script type="text/javascript">
        function onRemoveModel() {
            return confirm("Are you sure to delete selected models?");
        }

        function onSelectModel() {
            var lst = document.getElementById("<%=lstModels.ClientID %>");
            
            if (lst.selectedIndex < 0)
                return;
            var value = lst.options[lst.selectedIndex].value;
            
            document.getElementById("<%=hidSelectedModelID.ClientID %>").value = value;
            document.getElementById("<%=btnLoadProblems.ClientID %>").click();
        }

        function onAddModel() {
            var lst = document.getElementById("<%=ddlBrand.ClientID %>");

            if (lst.selectedIndex < 0)
                return false;
            var brandid = lst.options[lst.selectedIndex].value;
            var returnValue = window.showModalDialog('<%=GetEditModelNamePageLink() %>' + '&mode=new&BrandID=' + brandid, '', 'dialogWidth=500px;dialogHeight=200px;resizable=no;help=no;unadorned=yes;');
            return returnValue > 0;
        }

        function onEditModel() {
            var lst = document.getElementById("<%=lstModels.ClientID %>");

            if (lst.selectedIndex < 0) {
                alert('Please select an item!');
                return false;
            }
            var id = lst.options[lst.selectedIndex].value;
            var returnValue = window.showModalDialog('<%=GetEditModelNamePageLink() %>' + '&id=' + id + '&mode=edit', '', 'dialogWidth=500px;dialogHeight=200px;resizable=no;help=no;unadorned=yes;');
            return returnValue > 0;
        }
    </script>

    <table class="popuptoolbar" width="100%">
        <tr>
            <td style="vertical-align:middle; text-align:left">
                <asp:LinkButton class="tbbutton" ID="btnNew" runat="server" OnClientClick="window.close();">
                    <img src="Images/CloseButton.gif" /><asp:Label ID="label3" runat="server" Text="Close"></asp:Label>
                </asp:LinkButton>
                <asp:Image ImageUrl="~/Images/tbSep.png" runat="server" ID="imgSep" />
                <asp:LinkButton class="tblabel" ID="btnSearch" runat="server" OnClientClick="return false;" >
                    <img src="Images/trans.png" /><asp:Label ID="Label2" class="labelMessage" runat="server" Text="Brand:" ></asp:Label>
                </asp:LinkButton> 
                <asp:DropDownList ValidationGroup="Add" ID="ddlBrand" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlBrand_OnSelectedIndexChanged" ></asp:DropDownList>
                <asp:RequiredFieldValidator ValidationGroup="Add" ID="require1" runat="server" ControlToValidate="ddlBrand" Display="Dynamic" CssClass="requiredField"
                    ErrorMessage="required" Text="required"></asp:RequiredFieldValidator>
            </td>
        </tr>
    </table>
    
    
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PopupContentHolder" runat="server">
    <div>
        <table width="100%">
            <tr>
                <td style='vertical-align:top; width:200px'>
                    <table class="toolbar" width="200px">
                        <tr>
                            <td style="vertical-align:middle; text-align:left">
                                <asp:LinkButton ValidationGroup="Add" class="tbbutton" ID="btnAdd" runat="server" OnClientClick="return onAddModel();" OnClick="btnAdd_OnClick" >
                                    <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/AddRecord.gif" /><asp:Label
                                        ID="label5" runat="server" Text="Add"></asp:Label>
                                </asp:LinkButton>
                                <asp:LinkButton class="tbbutton" ID="btnEdit" runat="server" OnClientClick="return onEditModel();" OnClick="btnAdd_OnClick" >
                                    <asp:Image ID="Image4" runat="server" ImageUrl="~/Images/Edit.gif" /><asp:Label
                                        ID="label6" runat="server" Text="Edit"></asp:Label>
                                </asp:LinkButton>
                               <asp:LinkButton class="tbbutton" ID="btnDelete" OnClientClick="return onRemoveModel();" runat="server" OnClick="btnDelete_OnClick">
                                    <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/Delete.gif" /><asp:Label
                                        ID="label7" runat="server" Text="Delete" ToolTip="Delete selected models" ></asp:Label>
                                </asp:LinkButton>
                            </td>
                        </tr>
                    </table>
                    <asp:ListBox onclick='onSelectModel();' SelectionMode="Multiple" ID="lstModels" runat="server" Width="200px" Height="480px"  ></asp:ListBox>
                </td>
                <td style='vertical-align:top;'>
                    <asp:UpdatePanel ID="updateProblems" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <uc:RepairModelProblemList ID="lstProblems" runat="server" AllowPaging="true" AllowSelecting="true" AllowSorting="true"
                                SaveOnCommit="false" Width="100%" PageSize="15" ReadOnly="true" />
                  
                            <asp:Button ID="btnLoadProblems" runat="server" OnClick="btnLoadProblems_OnClick" style="display:none" />
                            <asp:HiddenField ID="hidSelectedModelID" runat="server" />
                            <div style="height:5px">&nbsp;</div>
                            <div style='text-align:center'>
                                <asp:Button ID="btnEditProblem" Visible="false" runat="server" Text="Edit" OnClick="btnEditProblem_OnClick" />
                                <asp:Button ID="btnCancelProblem" Visible="false" runat="server" Text="Cancel" OnClick="btnCancelProblem_OnClick" />
                                <asp:Button ID="btnUpdateProblem" Visible="false" runat="server" Text="Update" OnClick="btnUpdateProblem_OnClick" />
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <a target="_blank" href="Images/quotation-sample.jpg"><asp:Label ID="Label1" runat="server" class='labelNote' Text="(*) Select a brand, select a Phone-Model, then click edit to modify price for a specific problem. Click this link for more details... "></asp:Label></a> 
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
